import { useState, useEffect } from 'react'

export function useResize() {
  const [size, setSize] = useState({
    width: document.documentElement.clientWidth,
    height: document.documentElement.clientHeight
  })
  // 拖动窗口
  const handleRisize = () => {
    setSize({
      width: document.documentElement.clientWidth, // 获取浏览器宽高
      height: document.documentElement.clientHeight
    })
  }
  useEffect(() => {
    window.addEventListener('resize', handleRisize)
    return () => {
      window.removeEventListener('resize', handleRisize)
    }
  })
  return [size]
}
